function mnrelrazao() {
	$('#content').load("html/mantercontasreceber.html #pnlRelRazao", function() { 

    	$("#pnlRelParams").dialog({
		    modal: true,
		    buttons: {
		        Ok: function() {
		        	
		        	sendForm('#frmRelParams', function(data) {
		        		var x = open("html/relrazao.html", "Razão", "top=20, left=10, width=1100, height=600");
		        		x.focus;
		        		x.onload = function() {
				        	var lblData = x.document.getElementById('lblPrintDate');
		        			var dthr = new Date().toLocaleString().split(" ");
		        			$(lblData).text(dthr[0] + " às " + dthr[1] + " ");
		        			
		        			var tbBody = x.document.getElementById('tbBody');
		        			var tbFoot = x.document.getElementById('tbFoot');
		        			var grpHead = x.document.getElementById('grpHead');
		        			var grpFoot = x.document.getElementById('grpFoot');
		        			var detail = x.document.getElementById('trHead');
		        			var tr = null;
		        			var cliente   = 0;
		        			var cli_vrTit = 0;
		        			var cli_jur   = 0;
		        			var cli_vrRec = 0;
		        			var tot_vrTit = 0;
		        			var tot_jur   = 0;
		        			var tot_vrRec = 0;
		        			
		        			$(data.Records).each(function(index, ctrec) {
		        				if (cliente != ctrec.ad_id) {
		        					if (cliente > 0) {
		        						tr = $(grpFoot).clone();
			        					$(tr).find('#tdST1').html(cli_vrTit.formatMoney());
			        					$(tr).find('#tdST2').html(cli_jur.formatMoney());
			        					$(tr).find('#tdST3').html(cli_vrRec.formatMoney());
					        			$(tbBody).append(tr);
					        			
					        			cli_vrTit = 0;
					        			cli_jur   = 0;
					        			cli_vrRec = 0;
		        					}
		        					cliente = ctrec.ad_id;
		        					tr = $(grpHead).clone();
		        					
		        					$(tr).find('#pCliente').html(ctrec.ad_nome);
				        			$(tbBody).append(tr);
		        				}
		        				
		        				tr = $(detail).clone();
		        				$(tr).find('#tdData').html(ctrec.data);
		        				$(tr).find('#tdHistorico').html(ctrec.historico2);
		        				$(tr).find('#tdLote').html(ctrec.pd_lote);
		        				$(tr).find('#tdVcto').html(ctrec.vcto);
		        				$(tr).find('#tdVrTitulo').html(ctrec.vr_titulo);
		        				$(tr).find('#tdJuros').html(ctrec.juros);
		        				$(tr).find('#tdVrRecebido').html(ctrec.vr_recebido);
		        				$(tr).find('#tdTipo').html(ctrec.tipo);
			        			$(tbBody).append(tr);

			        			cli_vrTit = cli_vrTit + parseFloat(ctrec.vr_titulo.replace('.', '').replace(',', '.'));
			        			cli_jur   = cli_jur   + parseFloat(ctrec.juros.replace('.', '').replace(',', '.'));
			        			cli_vrRec = cli_vrRec + parseFloat(ctrec.vr_recebido.replace('.', '').replace(',', '.'));

			        			tot_vrTit = tot_vrTit + parseFloat(ctrec.vr_titulo.replace('.', '').replace(',', '.'));
			        			tot_jur   = tot_jur   + parseFloat(ctrec.juros.replace('.', '').replace(',', '.'));
			        			tot_vrRec = tot_vrRec + parseFloat(ctrec.vr_recebido.replace('.', '').replace(',', '.'));
		        			});
		        			
    						// group footer
		        			tr = $(grpFoot).clone();
        					$(tr).find('#tdTitulo').html("Subtotais:");
        					$(tr).find('#tdST1').html(cli_vrTit.formatMoney());
        					$(tr).find('#tdST2').html(cli_jur.formatMoney());
        					$(tr).find('#tdST3').html(cli_vrRec.formatMoney());
		        			$(tbBody).append(tr);

		        			// sumário
    						tr = $(grpFoot).clone();
        					$(tr).find('#tdTitulo').html("Total Geral:");
        					$(tr).find('#tdST1').html(tot_vrTit.formatMoney());
        					$(tr).find('#tdST2').html(tot_jur.formatMoney());
        					$(tr).find('#tdST3').html(tot_vrRec.formatMoney());
		        			$(tbFoot).append(tr);
		        			
		        			$(x.document.getElementById('btnPrint')).click(function() {
		        				$(this).hide();
		        				x.print();
		        				$(this).show();
		        			});
		        		};
		        	});
		            $(this).dialog("close");
		        },
		        Cancelar: function() {
		            $(this).dialog("close");
		        }
		    },
		    close: function() {
	            $(this).remove();
		    }
		});
	});
}